import { routes } from 'vue-router/auto-routes';
// import { PAGE_NOT_FOUND_NAME } from './constant';
// import component from 'element-plus/es/components/tree-select/src/tree-select-option.mjs';

const LOGIN_PATH = '/login';
const OmitList = [LOGIN_PATH];

function filterRoutes(routes: any[]) {
  const result = routes.filter(route => {
    return !OmitList.includes(route.path) && (route.meta = { hidden: true });
  });

  return result;
}

const rootRoute = {
  path: '/',
  name: 'Layout',
  redirect: '/home',
  component: () => import('@/layout/index.vue'),
  meta: {
    title: 'home page'
  },
  children: filterRoutes(routes)
};

const baseRoutes = [
  {
    path: '/login',
    name: 'Login',
    meta: {
      title: 'login'
    },
    component: () => import('@/views/login/index.vue'),
    children: []
  }
];

const redirectRoutes = [
  {
    path: '/:pathMatch(.*)*',
    meta: {
      title: 'PageNotFound',
      hideInMenu: true,
      hideInTabs: true
    },
    component: () => import('@/views/error/404.tsx')
  }
];

export default [rootRoute, ...baseRoutes, ...redirectRoutes];
